//
//  commodityDetailsView.m
//  XYMaterial
//
//  Created by 肖扬 on 15/12/30.
//  Copyright © 2015年 肖扬. All rights reserved.
//

#import "commodityDetailsView.h"
#import "homeModel.h"
@implementation commodityDetailsView
@synthesize obj,viewData,material_id;
-(id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        NSArray *arr1 = [NSArray arrayWithObjects:@"品牌",@"品种",@"等级",@"贴面工艺",@"花色",@"长度",@"宽度",@"厚度",@"地区", nil];
        NSArray *arr2 = [NSArray arrayWithObjects:@"品牌",@"品种",@"等级",@"花色",@"树种",@"高度",@"宽度",@"厚度",@"地区", nil];
        NSArray *arr3 = [NSArray arrayWithObjects:@"品牌",@"品种",@"型号",@"花色",@"克重",@"长度",@"宽度",@"地区", nil];
        self.viewData = [NSMutableArray arrayWithObjects:arr1,arr2,arr3, nil];
    }
    return self;
}
-(void)drawDetailsView:(detailsType)type detailsInformation:(id)obj{
    NSMutableArray *supply = (NSMutableArray *)obj;
    NSArray *arr = [self.viewData objectAtIndex:type];
    for (int i = 0; i <[arr count]; i++) {
        UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(10, 25*i, SWIDTH, 25)];
        lab.font = [UIFont systemFontOfSize:13];
        lab.backgroundColor = [UIColor clearColor];
        if ([[arr objectAtIndex:i]isEqualToString:@"长度"]||[[arr objectAtIndex:i]isEqualToString:@"宽度"]||[[arr objectAtIndex:i]isEqualToString:@"厚度"]||[[arr objectAtIndex:i]isEqualToString:@"高度"]) {
            if ([[supply objectAtIndex:i]isEqualToString:@""]) {
                break;
            }
        }
        lab.text = [arr objectAtIndex:i];
        lab.textColor = GRAYColor;
        [self addSubview:lab];
        
        UILabel *lab1 = [[UILabel alloc]initWithFrame:CGRectMake(140, 25*i, SWIDTH - 140, 25)];
        lab1.font = [UIFont systemFontOfSize:13];
        lab1.backgroundColor = [UIColor clearColor];
        lab1.text = [supply objectAtIndex:i];
        [self addSubview:lab1];
        if (type == plankDetailsType) {
            NSLog(@"板材");
            if ([[arr objectAtIndex:i]isEqualToString:@"长度"]||[[arr objectAtIndex:i]isEqualToString:@"宽度"]||[[arr objectAtIndex:i]isEqualToString:@"厚度"]||[[arr objectAtIndex:i]isEqualToString:@"高度"]) {
                if ([[supply objectAtIndex:i]isEqualToString:@"0"]||[[supply objectAtIndex:i] isEqualToString:@"0.0"]) {
                    lab1.text = @"";
                }else{
                    NSString *str = [NSString stringWithFormat:@"%@mm",[supply objectAtIndex:i]];
                    lab1.text = str;
                }
            }
        }else if (type == doorplankDetailsType){
            NSLog(@"门板");
            if ([[arr objectAtIndex:i]isEqualToString:@"长度"]||[[arr objectAtIndex:i]isEqualToString:@"宽度"]||[[arr objectAtIndex:i]isEqualToString:@"厚度"]||[[arr objectAtIndex:i]isEqualToString:@"高度"]) {
                if ([[supply objectAtIndex:i]isEqualToString:@"0"]||[[supply objectAtIndex:i] isEqualToString:@"0.0"]) {
                    lab1.text = @"";
                }else{
                    NSString *str = [NSString stringWithFormat:@"%@mm",[supply objectAtIndex:i]];
                    lab1.text = str;
                }
            }
        }else if (type == paperDetailsType){
            NSLog(@"装饰纸");
            if ([[arr objectAtIndex:i]isEqualToString:@"长度"]||[[arr objectAtIndex:i]isEqualToString:@"宽度"]||[[arr objectAtIndex:i]isEqualToString:@"厚度"]||[[arr objectAtIndex:i]isEqualToString:@"高度"]) {
                if ([[supply objectAtIndex:i]isEqualToString:@"0"]||[[supply objectAtIndex:i] isEqualToString:@"0.0"]) {
                    lab1.text = @"";
                }else{
                    NSString *str = [NSString stringWithFormat:@"%@尺",[supply objectAtIndex:i]];
                    lab1.text = str;
                }
            }
        }
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
